/**
 * @file:air_conditioning.h
 * @brief:分层状态机
 * @author:liaowx
 * @date:2019.08.02
 */
#ifndef __AIR_CONDITIONING_H__
#define __AIR_CONDITIONING_H__

enum EVENT {
    OPEN = 1,
    CLOSE,
    MAKE_COLD,
    MAKE_HOT,
    INIT,
    ENTRY,
    EXIT
};

typedef struct air_conditioning air_conditioning_t;

typedef struct air_conditioning* (* HSM_FN)(struct air_conditioning *cur_state,
                                enum EVENT event);

struct air_conditioning {
    char *name;
    HSM_FN handler;
    int level;
    struct air_conditioning *parent;
    int temperature;
    int wind_speed;
};

extern void state_init(struct air_conditioning *state,
                char *name, int temperature, int wind_speed,
                HSM_FN handler, struct air_conditioning *parent);
extern struct air_conditioning *state_run(struct air_conditioning *cur_state,
                        enum EVENT event);
extern struct air_conditioning *tran(struct air_conditioning *cur_state,
                    struct air_conditioning *next_state);
extern struct air_conditioning *state_creat(struct air_conditioning *cur_state,
                    struct air_conditioning *init_state);



#endif